package coms.action;

import com.opensymphony.xwork2.Action;
import coms.delegates.KeywordDelegate;
import coms.delegates.KeywordDelegate;
import coms.dto.Keyword;
import coms.dto.Keyword;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class KeywordAction extends ComsActionSupport implements IAction{
    
   private Keyword keyword;
   private List<Keyword> keywordList;
   
   private KeywordDelegate keywordDelegate;
   
    
    public KeywordAction() {
        keyword = new Keyword();
        keywordDelegate = new KeywordDelegate();
    }
    
   
    @Override
      public String input(){
        try {
            keywordList = keywordDelegate.findAll();
        } catch (Exception ex) {
            Logger.getLogger(KeywordAction.class.getName()).log(Level.SEVERE, null, ex);
        }
        return "input";
    }
      
    @Override
    public String create(){
        
        keywordDelegate.create(keyword);
        return Action.SUCCESS;
    }
    
    @Override
    public String update(){
        keywordDelegate.update(keyword);
        return Action.SUCCESS;
    }
    
    @Override
    public String delete(){
          keywordDelegate.delete(keyword);
        return Action.SUCCESS;
    }
   
    public Keyword getKeyword() {
        return keyword;
    }

    public void setKeyword(Keyword keyword) {
        this.keyword = keyword;
    }

    @Override
    public String findAll() {
        try {
            keywordList = keywordDelegate.findAll();
        } catch (Exception ex) {
            Logger.getLogger(KeywordAction.class.getName()).log(Level.SEVERE, null, ex);
        }
        return Action.SUCCESS;
    }

    @Override
    public String search() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String edit() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
